package com.tutu.controller.backend;

import com.tutu.controller.common.CommonController;
import com.tutu.service.GatewayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 日志管理
 */
@Controller
@RequestMapping(value = "backend/gateway")
public class GatewayController extends CommonController {

    @Autowired
    GatewayService gatewayService;

    @RequestMapping(value = "/index")
    public String index(Model model) {
        model.addAttribute("gatewayList", gatewayService.findList());

        return "backend/gateway/list";
    }

    @RequestMapping("/update")
    @ResponseBody
    public Map<String, Object> update(HttpServletRequest request, String path, String comment) {
        return gatewayService.modifyInfo(request, path, comment);
    }

    @RequestMapping("/delete")
    @ResponseBody
    public Map<String, Object> delete(HttpServletRequest request, String path) {
        return gatewayService.delInfo(request, path);
    }
}
